package com.sunxy.bluetoothdemo

import android.Manifest
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.common.frame.kt.asAutoDisposable
import com.common.frame.utils.ListUtils
import com.common.frame.utils.PermissionForResultUtils

/**
 *
 *
 * @author: sunxy11
 * @email: sunxy11@iflytek.com
 * @date: 2022/10/18
 */
class MainActivity: AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        PermissionForResultUtils.getFragment(this)
            .request(
                Manifest.permission.BLUETOOTH,
                Manifest.permission.BLUETOOTH_ADMIN,
                Manifest.permission.ACCESS_FINE_LOCATION,
                Manifest.permission.ACCESS_COARSE_LOCATION)
            .subscribe({
                if (ListUtils.isNull(it.deniedPermissionExplain)) {
                    startActivity(Intent(this@MainActivity, BlueToothActivity::class.java))
                    finish()
                }
            },{})
            .asAutoDisposable(lifecycle)
    }
}